home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / RossettMADF Library / RDriver.h < prev    next >
Encoding:
Text File  |  1994-09-18  |  7.4 KB  |  241 lines  |  [TEXT/MMCC]

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 4.2 -- MAD Music Driver Definition
  4. //
  5. //    Library Version 2.5
  6. //
  7. //    To use with MusicLibrary 2.5 for Think C & CodeWarrior
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //    
  14. //    FAX:            (+41 22) 346 11 97
  15. //    Compuserve:        100277,164
  16. //    Internet:         rosset@dial.eunet.ch
  17. //
  18. /********************                        ***********************/
  19.  
  20. #define MAX_ARP 3
  21. #define NUMBER_FINETUNES 17
  22. #define AMIGA_CLOCKFREQ 33659820
  23. #define MIN_PITCH 142
  24. #define MAX_PITCH 17161L
  25. #define MIN_VOLUME 0
  26. #define MAX_VOLUME 64
  27. #define ACCURACY 12
  28. #define fix_to_int(x) ((x) >> ACCURACY)
  29. #define int_to_fix(x) ((x) << ACCURACY)
  30. #define    FREQBASE        152L
  31. #define MAXTRACK        32
  32. #define MAXINSTRU        64
  33. #define MAXPATTERN        200
  34. #define NUMBER_NOTES    84
  35.  
  36. /********************                        ***********************/
  37. /***                  Voice structure definition                    ***/
  38. /********************                        ***********************/
  39.  
  40. struct VoiceActive    {
  41.         Ptr            MaxPtr;
  42.         Ptr            InstruVoice;
  43.         Ptr            StartPtr;
  44.         long        loopWord;
  45.         long        loopWords;
  46.         
  47.         short        Instru;
  48.         short        InstruOld;
  49.         
  50.         short        Amiga;
  51.         short        AmigaOld;
  52.         
  53.         short        pitch;
  54.         short         realpitch;
  55.         
  56.         short        volume;
  57.         short         effect;
  58.         Byte        arg;
  59.         
  60.         short         arp[MAX_ARP];
  61.         short         arpindex;
  62.         
  63.         short        viboffset;
  64.         short         vibdepth;
  65.         short         slide;
  66.         short         pitchgoal;
  67.         short         pitchrate;
  68.         short        oldpitchrate;
  69.         short         volumerate;
  70.         short         vibrate;
  71.         short        oldvibrate;
  72.         short         retrig;
  73.         
  74.         short        ID;
  75.         short        amplitude;
  76. };
  77. typedef        struct VoiceActive    VoiceActive;
  78.  
  79. /********************                        ***********************/
  80. /***              Music description used in driver                ***/
  81. /********************                        ***********************/
  82.  
  83. struct    MADPartition
  84. {
  85.         MADSpec*                header;
  86.         struct    MusicPattern*    partition[ MAXPATTERN];
  87.         Ptr                        instrument[ MAXINSTRU];
  88. };
  89. typedef        struct MADPartition    MADPartition;
  90.  
  91. /********************                        ***********************/
  92. /***                    PlayerPRO variables                        ***/
  93. /********************                        ***********************/
  94.  
  95. #ifdef MainSystemPlayerPRO
  96. #define EXT
  97. #else
  98. #define EXT extern
  99. #endif
  100.  
  101. EXT    MADPartition            thePartition;                        // Current music in memory, loaded with RLoadMusic() by example
  102. EXT    MADSpec                    *theFileInt;                        // Current music header == thePartition.header
  103. EXT    VoiceActive                theVoiceActive[ MAXTRACK];            // Current driver voices
  104. EXT    short                    DriverTypeInt;                        // Actual driver type
  105. EXT    short                    Tube[ MAXTRACK];                    // Used in 'Tracks View' Window - View menu
  106. EXT short                    PartitionReader;                    // Current position in pattern (0...64)
  107. EXT short                    Pat;                                // Current ID Pattern, see 'Patterns list'
  108. EXT short                    PL;                                    // Current position in partition, see 'Partition list'
  109. EXT    short                    VolExt[ MAXTRACK];                    // Volumes settings, see 'Adaptators' window
  110. EXT    short                    speed;                                // Current speed, see speed Effect
  111. EXT    short                    finespeed;                            // Current finespeed, see speed Effect
  112. EXT    short                    InstruTube[ MAXINSTRU];                // Used in 'Instrument View' Window - View menu
  113. EXT    short                    VExt;                                // External music speed, see 'Adaptators' window
  114. EXT    short                    FreqExt;                            // External music pitch, see 'Adaptators' window
  115. EXT    short                    DriveTrackNo;                        // Actual number of tracks
  116. EXT    short                    DriveOutBit;                        // Output bit: 8 or 16 bits
  117. EXT    Boolean                    PtrSystem;                            // Use NewPtr or NewPtrSys ?
  118. EXT    Boolean                    Reading;                            // Reading indicator
  119. EXT    Boolean                    MusiqueFertig;                        // Is your music finished?
  120.  
  121. /* DO NOT MODIFY OR USE these variables */
  122.  
  123. EXT short                    smallcounter, trackDiv;
  124. EXT    long                    DBTick, ASCBUFFER;
  125. EXT    short                    **FreqHandle, InstruActif[ MAXINSTRU];
  126. EXT    Ptr                        SysHeapPtr, Vol, IntPtr[ 2], PseudoBuf[ 2];
  127. EXT    Boolean                    SMTicker, RepeatMusic, JumpToNextPattern;
  128. EXT    long                    oldNotePosAA, SInc, VMOD;
  129. EXT    Boolean                    DriveStereo, PtrSystem, JumpToNextPattern, RepeatMusic;
  130.  
  131. extern    short    Tuning[ ], vibrato_table[ ];
  132.  
  133. /********************                        ***********************/
  134. /***                        DRIVERS ID                            ***/
  135. /***             DO NOT USE MIDIClassic Driver !!!!                ***/
  136. /********************                        ***********************/
  137.  
  138. enum {
  139.     ASCMono = 1,
  140.     ASCStereo = 2,
  141.     SMMono = 3,
  142.     SMStereo = 4,
  143.     SMDSP = 5,
  144.     SMPolyPhonic = 6,
  145.     MIDIClassic = 7
  146. };
  147.  
  148. /********************                        ***********************/
  149. /***                        EFFECTS ID                            ***/
  150. /********************                        ***********************/
  151.  
  152. enum {
  153.         arpeggioE         = 0,
  154.         downslideE         = 1,
  155.         upslideE         = 2,
  156.         portamentoE     = 3,
  157.         vibratoE         = 4,
  158.         portaslideE     = 5,
  159.         vibratoslideE    = 6,
  160.         nothingE         = 7,
  161.         offsetE         = 9,
  162.         slidevolE         = 10,
  163.         fastskipE         = 11,
  164.         volumeE         = 12,
  165.         skipE             = 13,
  166.         extendedE         = 14,
  167.         speedE             = 15
  168.     };
  169.  
  170. /********************                        ***********************/
  171. /*                General Function Description                      */
  172. /*      For more informations about these functions, e-mail me    */
  173. /********************                        ***********************/
  174.  
  175.  
  176. /********************                        ***********************/
  177. /***                     EXTERNAL ROUTINES                         ***/
  178. /*** See Documentation for more informations on these routines  ***/
  179. /********************                        ***********************/
  180.  
  181. OSErr    RInitMusic( short, short);                    // Music Driver initialization
  182. OSErr    RPlayMusic( void);                            // Play the current music
  183. OSErr    RStopMusic( void);                            // Stop the current music
  184. OSErr    RResetMusic( void);                            // Reset the current music at the start position
  185. OSErr    RQuitMusic( void);                            // Dispose the music driver, use it after RInitMusic()
  186.  
  187. OSErr    RLoadMusic( Str255 fName);                    // Load a MAD File in the current directory
  188. OSErr    RLoadMusicRsrc( OSType IDName, short IDNo);    // Load a MAD Rsrc into memory
  189. OSErr    RInstallMADF( MADPartition aPartition);        // Install directly a MAD partition
  190. OSErr    RClearMusic(void);                            // Dispose the current music, use it after RLoadMusic(), RLoadMusicRsrc(), RInstallMADF()
  191.  
  192.  
  193. void    ConvertMod2Mad( Ptr aMOD, long Size, MADPartition *theMAD);    // Convert MOD to MAD
  194. Ptr        ConvertMad2Mod( MADPartition *theMAD, long Size);            // Convert MAD to MOD
  195. void    ChangeTrackNo( short);                        // Change the current tracks number of the music driver
  196. void    CleanDriver( void);                            // Clean the driver
  197. struct Command* GetCommand( short PosX, short    TrackIdX, struct MusicPattern*    tempMusicPat);    // Extract a Command from a MusicPattern    
  198.  
  199. /********************                        ***********************/
  200. /***                     INTERNAL ROUTINES                        ***/
  201. /***                DO NOT use these routines                    ***/
  202. /********************                        ***********************/
  203.  
  204. void    Sampler8in8Add( VoiceActive *curVoice, register Ptr    ASCBuffer);
  205. void    Sampler16Add( VoiceActive *curVoice, register short    *ASCBuffer);
  206.  
  207. void    NoteAnalyse( void);
  208.  
  209. void    ClearVol4();
  210. OSErr    SetUpFrequence( long, long);
  211. OSErr    ReadInstrument( short, Boolean, Handle);
  212. void    DoEffect( VoiceActive *, short);
  213. OSErr    DBSndClose();
  214. void    StopChannel();
  215. OSErr     SetMODVol4( long , long , Boolean );
  216. void    PlayChannel();
  217. void     checkpitch( VoiceActive *, Boolean);
  218. void     BufferCopyM();
  219. void     BufferCopyS();
  220. void    InstallMODVBL(void);
  221. void     ReadNote( VoiceActive *curVoice, struct Command        *theCommand);
  222. void    RemoveMODVBL(void);
  223. void    MODRelance(void);
  224. void    Play(void);
  225. void    VIAOn(void);
  226. void     SndOff(void);
  227. void     SndOn(void);
  228. void    VIAOn2(void);
  229. void     VIAOn3(void);
  230. OSErr    InitDBSoundManager( long);
  231. void     SetUpEffect( VoiceActive *ch);
  232. Boolean DirectSave( Ptr, Boolean, short);
  233. void    ChangeSpeed( void);
  234. void    Play16Stereo( void);
  235. void    Play8Stereo( void);
  236. void    Play8Mono( void);
  237. long    decode32 (void *msg_buf);
  238. short    decode16 (void *msg_buf);
  239. long    Tdecode32 (void *msg_buf);
  240. short    Tdecode16 (void *msg_buf);
  241. void     ClearFrequence();